From a966ed3269c33570848c78d5006a7c665de09049 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 20 Apr 2005 13:00:18 +0000 Subject: [PATCH] bitkeeper revision 1.1338.1.1 (42665262XHUfWrT775PaPvnAkL5qXg) Fix assumption about size of irq_cpustat_t in assembly code. Signed-off-by: Keir Fraser --- xen/arch/x86/x86_32/asm-offsets.c | 10 ++++++++++ xen/arch/x86/x86_32/entry.S | 4 ++-- xen/arch/x86/x86_64/asm-offsets.c | 10 ++++++++++ xen/arch/x86/x86_64/entry.S | 15 ++++++--------- xen/include/asm-x86/config.h | 10 +++------- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/x86_32/asm-offsets.c b/xen/arch/x86/x86_32/asm-offsets.c index ee605b9471..1a16ab2111 100644 --- a/xen/arch/x86/x86_32/asm-offsets.c +++ b/xen/arch/x86/x86_32/asm-offsets.c @@ -15,6 +15,13 @@ #define OFFSET(_sym, _str, _mem) \ DEFINE(_sym, offsetof(_str, _mem)); +/* base-2 logarithm */ +#define __L2(_x) (((_x) & 0x00000002) ? 1 : 0) +#define __L4(_x) (((_x) & 0x0000000c) ? ( 2 + __L2( (_x)>> 2)) : __L2( _x)) +#define __L8(_x) (((_x) & 0x000000f0) ? ( 4 + __L4( (_x)>> 4)) : __L4( _x)) +#define __L16(_x) (((_x) & 0x0000ff00) ? ( 8 + __L8( (_x)>> 8)) : __L8( _x)) +#define LOG_2(_x) (((_x) & 0xffff0000) ? (16 + __L16((_x)>>16)) : __L16(_x)) + void __dummy__(void) { OFFSET(XREGS_eax, struct xen_regs, eax); @@ -78,4 +85,7 @@ void __dummy__(void) BLANK(); DEFINE(FIXMAP_apic_base, fix_to_virt(FIX_APIC_BASE)); + BLANK(); + + DEFINE(IRQSTAT_shift, LOG_2(sizeof(irq_cpustat_t))); } diff --git a/xen/arch/x86/x86_32/entry.S b/xen/arch/x86/x86_32/entry.S index c860e48937..aa35590d27 100644 --- a/xen/arch/x86/x86_32/entry.S +++ b/xen/arch/x86/x86_32/entry.S @@ -140,7 +140,7 @@ vmx_test_all_events: cli # tests must not race interrupts /*test_softirqs:*/ movl EDOMAIN_processor(%ebx),%eax - shl $6,%eax # sizeof(irq_cpustat) == 64 + shl $IRQSTAT_shift,%eax test %ecx,SYMBOL_NAME(irq_stat)(%eax,1) jnz vmx_process_softirqs @@ -270,7 +270,7 @@ test_all_events: cli # tests must not race interrupts /*test_softirqs:*/ movl EDOMAIN_processor(%ebx),%eax - shl $6,%eax # sizeof(irq_cpustat) == 64 + shl $IRQSTAT_shift,%eax test %ecx,SYMBOL_NAME(irq_stat)(%eax,1) jnz process_softirqs /*test_guest_events:*/ diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c index d05bb2b7af..787c5ffea4 100644 --- a/xen/arch/x86/x86_64/asm-offsets.c +++ b/xen/arch/x86/x86_64/asm-offsets.c @@ -15,6 +15,13 @@ #define OFFSET(_sym, _str, _mem) \ DEFINE(_sym, offsetof(_str, _mem)); +/* base-2 logarithm */ +#define __L2(_x) (((_x) & 0x00000002) ? 1 : 0) +#define __L4(_x) (((_x) & 0x0000000c) ? ( 2 + __L2( (_x)>> 2)) : __L2( _x)) +#define __L8(_x) (((_x) & 0x000000f0) ? ( 4 + __L4( (_x)>> 4)) : __L4( _x)) +#define __L16(_x) (((_x) & 0x0000ff00) ? ( 8 + __L8( (_x)>> 8)) : __L8( _x)) +#define LOG_2(_x) (((_x) & 0xffff0000) ? (16 + __L16((_x)>>16)) : __L16(_x)) + void __dummy__(void) { OFFSET(XREGS_r15, struct xen_regs, r15); @@ -77,4 +84,7 @@ void __dummy__(void) OFFSET(MULTICALL_arg3, multicall_entry_t, args[3]); OFFSET(MULTICALL_arg4, multicall_entry_t, args[4]); OFFSET(MULTICALL_result, multicall_entry_t, args[5]); + BLANK(); + + DEFINE(IRQSTAT_shift, LOG_2(sizeof(irq_cpustat_t))); } diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S index 9254cf76e4..e6ee0e8fd3 100644 --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -130,7 +130,7 @@ test_all_events: cli # tests must not race interrupts /*test_softirqs:*/ movl EDOMAIN_processor(%rbx),%eax - shl $6,%rax # sizeof(irq_cpustat) == 64 + shl $IRQSTAT_shift,%rax leaq SYMBOL_NAME(irq_stat)(%rip),%rcx testl $~0,(%rcx,%rax,1) jnz process_softirqs @@ -237,16 +237,13 @@ ENTRY(vmx_asm_do_resume) vmx_test_all_events: GET_CURRENT(%rbx) /* test_all_events: */ - xorq %rcx,%rcx - notq %rcx cli # tests must not race interrupts /*test_softirqs:*/ - movq EDOMAIN_processor(%rbx),%rax -#if 0 - shl $6,%rax # sizeof(irq_cpustat) == 64 - test %rcx,SYMBOL_NAME(irq_stat)(%rax,1) -#endif - jnz vmx_process_softirqs + movl EDOMAIN_processor(%rbx),%eax + shl $IRQSTAT_shift,%rax + leaq SYMBOL_NAME(irq_stat)(%rip), %rdx + testl $~0,(%rdx,%rax,1) + jnz vmx_process_softirqs vmx_restore_all_guest: call SYMBOL_NAME(load_cr2) diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h index 2b20297a6e..015e79022a 100644 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -16,7 +16,9 @@ #define CONFIG_X86_LOCAL_APIC 1 #define CONFIG_X86_GOOD_APIC 1 #define CONFIG_X86_IO_APIC 1 -#define CONFIG_X86_L1_CACHE_SHIFT 5 + +/* Intel P4 currently has largest cache line (L2 line size is 128 bytes). */ +#define CONFIG_X86_L1_CACHE_SHIFT 7 #define CONFIG_ACPI 1 #define CONFIG_ACPI_BOOT 1 @@ -53,12 +55,6 @@ #define OPT_CONSOLE_STR "com1,vga" -/* - * Just to keep compiler happy. - * NB. DO NOT CHANGE SMP_CACHE_BYTES WITHOUT FIXING arch/i386/entry.S!!! - * It depends on size of irq_cpustat_t, for example, being 64 bytes. :-) - */ -#define SMP_CACHE_BYTES 64 #define NR_CPUS 16 /* Linkage for x86 */ -- 2.30.2